package controller;

import exception.SomeException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;

/**
 * Author:shixiaojun@itany.com
 * Date:2022/7/28 11:19
 * Version:1.0-SNAPSHOT
 * Description:
 */
@Controller
@RequestMapping(value = "/hello")
public class HelloAnnotationController {

    @RequestMapping("/f1")
//    @RequestMapping
    public ModelAndView f1() throws SomeException {
        ModelAndView mav = new ModelAndView();
        mav.setViewName("hello");
        mav.addObject("msg","Hello Annotation");
//        return mav;
        throw new SomeException("执行HelloController遇到了异常");
    }

    @RequestMapping("/f2")
//    @RequestMapping
    public String f2(HttpServletRequest request){
        int i = 1/0;
        request.setAttribute("msg","Hello SpringMVC Annotation");
        return "hello";
    }

}
